package com.fzrskj.cloud.free.core.enums;

/**
 * UserTypeEnum.
 *
 * @author zj.
 *         Created on 2018/12/5 0005.
 */
public enum UserTypeEnum {
    /**
     * 个人.
     */
    INDIVIDUAL(1, "个人"),
    /**
     *  公司/组织.
     */
    ORGANIZATION(2, "公司");

    /**
     * 值.
     */
    private int type;

    /**
     * 名称
     */
    private String name;

    /**
     * construct.
     * @param type 值.
     */
    UserTypeEnum(int type, String name) {
        this.type = type;
        this.name = name;
    }

    /**
     * 是否等于.
     * @param comparisonType 对比值.
     * @return
     */
    public Boolean equals(int comparisonType) {
        return this.type == comparisonType;
    }

    /**
     * get type.
     * @return type.
     */
    public int getType() {
        return this.type;
    }

    /**
     * get name.
     * @return name.
     */
    public String getName() {
        return name;
    }

    /**
     * get name by type.
     * @param type type.
     * @return name.
     */
    public static String getName(String type) {
        for (UserTypeEnum typeEnum : UserTypeEnum.values()) {
            if (typeEnum.equals(type)) {
                return typeEnum.getName();
            }
        }
        return null;
    }
}
